<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/echarts.min.js"></script>
		<script src="js/jquery-3.4.0.min.js"></script>

		<!-- //展示访问量前十的IP地址(柱状图) -->
		<div id="top10_ipaddress" style="width: 600px;height: 400px;">
			<script type="text/javascript">
				var myEchar = echarts.init(document.getElementById('top10_ipaddress'));
				myEchar.showLoading();
				myUser = {
					"userid": 1
				}
				$.ajax({
					contentType: "application/json;charset=utf-8",
					type: "put",
					url: "http://localhost:8082/mylog/getIPaddress",
					data: JSON.stringify(myUser),
					dataType: "json",
					success: function(res) {
						console.log(res);
						if (res) {
							var res1 = new Array();
							var res2 = new Array();
							for (var i in res){
								res1[i] = res[i].name;
								res2[i] = res[i].value;
							}
							console.log(res1);
							myEchar.hideLoading()
							myEchar.setOption({
								title: {
									text: '访问量前十的IP地址',
									left: 'center'
								},
								  tooltip: {
								    trigger: 'axis',
								    axisPointer: {
								      type: 'shadow'
								    }
								  },
								  grid: {
								    left: '3%',
								    right: '4%',
								    bottom: '3%',
								    containLabel: true
								  },
								  xAxis: [
								    {
								      type: 'category',
								      data: res1,
								      axisTick: {
								        alignWithLabel: true
								      },
									  axisLabel:{
										  interval:0
									  }
								    }
								  ],
								  yAxis: [
								    {
								      type: 'value',
									  splitNumber: 3
								    }
								  ],
								  series: [
								    {
								      name: '访问量',
								      type: 'bar',
								      barWidth: '60%',
								      data: res2
								    }
								  ]
							});
						}
					},
					error: function(errorMag) {
						alert("用户状态分析数据加载失败");
						myEchar.hideLoading();
					}
				});
				
				
			</script>
		</div>
	</head>
	<body>
	</body>
</html>
